#include "gameover.h"
#include "ui_gameover.h"
#include "mainwindow.h"
#include "game.h"
Gameover::Gameover(MainWindow *m,QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Gameover)
{
    this->setWindowFlags(Qt::FramelessWindowHint);
    this->setAttribute(Qt::WA_TranslucentBackground);

    ui->setupUi(this);
    mainwindow=m;
    ui->toolButton->setVisible(false);
    ui->toolButton_4->setVisible(false);
}

Gameover::~Gameover()
{
    delete ui;
}

void Gameover::win()
{
    ui->label->setPixmap(QPixmap(":/img/win.png"));
    ui->toolButton->setVisible(true);
}

void Gameover::lose()
{
    ui->label->setPixmap(QPixmap(":/img/lose.png"));
    ui->toolButton_4->setVisible(true);
}

void Gameover::on_toolButton_2_clicked()  //返回主菜单
{
    mainwindow->changeWindow(0);
    this->accept();
}

void Gameover::on_toolButton_4_clicked() //重新开始
{
    mainwindow->game->loadscene(mainwindow->game->id);
    this->accept();
}

void Gameover::on_toolButton_clicked()  //下一关
{
    mainwindow->game->loadscene(mainwindow->game->id+1);
    this->accept();
}

void Gameover::on_toolButton_3_clicked() //选择关卡
{
    mainwindow->changeWindow(1);
    this->accept();
}
